#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 3e5 + 5;
const int M = 1e9 + 7;

int t, n, q;
string s;

int pre[N];

int main()
{
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> t;
    while (t--)
    {
        cin >> n >> q >> s;

        pre[0] = 0;
        for (int i = 1; i <= n; i++)
        {
            int d = s[i - 1] == '+' ? 1 : -1;
            if (i & 1)
                pre[i] = pre[i - 1] + d;
            else
                pre[i] = pre[i - 1] - d;
        }

        while (q--)
        {
            int l, r;
            cin >> l >> r;
            int f = pre[r] - pre[l - 1];

            if (f == 0)
                cout << 0 << endl;
            else if (f & 1)
                cout << 1 << endl;
            else
                cout << 2 << endl;
        }
    }
    return 0;
}